use Dosvid
go

if exists(select 1
		  from sysobjects
		  where name = 'Vacancy_Territories')
  drop table Vacancy_Territories
go

create table Vacancy_Territories
(
  Id int identity(1,1) not null,
  VacancyId int not null,
  TerritoryId int not null
)  
go

alter table Vacancy_Territories add constraint PK_Vacancy_Territories_ID primary key(Id)
go

create nonclustered index IX_Vacancy_Territories_VacancyId on Vacancy_Territories
       (VacancyId asc)
go

alter table Vacancy_Territories add constraint FK_Vacancy_Territories_TeretoryId 
      foreign key (TerritoryId) references Territories(Id) 
go

alter table Vacancy_Territories add constraint FK_Vacancy_Territories_CandidateId 
      foreign key (VacancyId) references Vacancies(Id) 
go
